package com.xiu.java8.lambda;

import java.util.Arrays;
import java.util.Comparator;

//使用 Lambdas 排序集合
public class LambdaTtest3 {
	
	public static void main(String[] args) {
		String[] players = {"Rafael Nadal", "Novak Djokovic",   
			    "Stanislas Wawrinka", "David Ferrer",  
			    "Roger Federer", "Andy Murray",  
			    "Tomas Berdych", "Juan Martin Del Potro",  
			    "Richard Gasquet", "John Isner"}; 
		String players2[]=Arrays.copyOf(players,players.length);
		String players3[]=Arrays.copyOf(players,players.length);
		Arrays.sort(players, new Comparator<String>() {
			@Override
			public int compare(String o1, String o2) {
				return o1.compareTo(o2);
			}
		});
		System.out.println(Arrays.toString(players));
		System.out.println(Arrays.toString(players2));
		System.out.println('A'-'D');
		Arrays.sort(players2, (o1,o2)->o1.compareTo(o2));
		System.out.println(Arrays.toString(players2));
		
		Arrays.sort(players3, (o1,o2)->o1.length()-o2.length());
		System.out.println(Arrays.toString(players3));
	}

}
